package com.dalin.platform.loa.action;

import com.dalin.framework.action.StrutsTwoAction;
import com.dalin.platform.loa.service.LoaService;
import com.dalin.platform.loa.vo.LoaUserVo;
/*****************************************************************************
 * @content: 类信息                                                   *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2010-06-03                                                     *
 * @modDate: 2010-06-03                                                     *
 * @version: 1.00                                                           *
 ****************************************************************************/
public class UserAddModAction extends StrutsTwoAction {
	private LoaService loaService; // 
    private LoaUserVo vo; // 

    public String execute() throws Exception {
    	Long projectId = getCurrentUser().getProjectId();
    	// 用户名唯一校验 begin
    	boolean duplicateLoginName = loaService.isExistLoginName(
    			vo.getUserId(), vo.getLoginName());
    	if (duplicateLoginName) {
        	setResContent(false, "此用户名已经被创建");
        	return null;
        }
    	// 用户名唯一校验 over
    	try {
    		if (vo.getUserId() == null) {
            	loaService.addLoaUser(projectId, vo);
            } else {
            	loaService.modifyLoaUser(vo);
            }
            setResContent(true, "保存成功");
    	} catch(Exception e) {
    		setResContent(e);
    	}
        return null;
    }





	public LoaService getLoaService() {
		return loaService;
	}





	public void setLoaService(LoaService loaService) {
		this.loaService = loaService;
	}





	public LoaUserVo getVo() {
		return vo;
	}





	public void setVo(LoaUserVo vo) {
		this.vo = vo;
	}

    
}
